package org.example.ui;

import org.apache.ibatis.session.SqlSession;
import org.example.entity.Condition;
import org.example.entity.Student;
import org.example.mapper.StudentMapper;
import org.example.util.MyBatisUtil;

import java.util.List;
import java.util.Scanner;

public class SearchStudentsByCondition {
    public static void main(String[] args) {
        SqlSession sqlSession= MyBatisUtil.getSession();
        StudentMapper studentMapper =sqlSession.getMapper(StudentMapper.class);
        Scanner input=new Scanner(System.in);
        System.out.println("请输入姓名:");
        String name=input.nextLine();
        System.out.println("请输入开始年龄：");
        int startAge=input.nextInt();
        System.out.println("请输入结束年龄：");
        int endAge=input.nextInt();
        Condition condition=new Condition(name,startAge,endAge);
        List<Student> list= studentMapper.getStudentsByCondition(condition);
        for (Student student:list){
            System.out.println(student.toString());
        }
    }
}
